home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 43
/
Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso
/
-serious-
/
comms
/
other
/
ums
/
rexx
/
wakeup.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-06-14
|
5KB
|
201 lines
/* ------------------------------------------------------------------------
WakeUp.rexx --
Get sleeping user out of bed by softly talking to him.
Requirements: upd running.
(Could be easily changed to use "SPEAK:" or "Utilities/Say" instead.)
------------------------------------------------------------------------ */
options results
RC = 0
signal on BREAK_C
signal on BREAK_D
signal on BREAK_E
signal on BREAK_F
signal on ERROR
signal on HALT
signal on IOERR
signal on SYNTAX
/*** Init ***/
call addlib("rexxdossupport.library", 0, -30)
call addlib("ums.library", 0, -210, 11)
call UMSInitConsts()
/*** Arguments ***/
ProgramName = "ReadMessage";
ArgsTemplate = "NAME,PASSWORD,SERVER/K"
args.SERVER = ""
args.PASSWORD = ""
parse arg arguments
if strip(arguments) = '?' then do
call writech(STDOUT, ArgsTemplate || ': ')
arguments = readln(STDIN)
end; else nop
if ~ReadArgs(arguments,ArgsTemplate,"args.") then do
say Fault(RC, ProgramName)
exit 10
end; else nop
/*** Login ***/
account = UMSLogin(args.name, args.password, args.server)
if account = 0 then do
say "unable to login."
exit 10
end
/*** Do the magic ***/
call UMSSelectField(account,L,UMSMakeFlags(0),,,,UMSCODE_GROUP,"",1);
call CheckErr
call UMSSelectField(account,L,UMSMakeFlags(1),,,,UMSCODE_FOLDER,"",1);
call CheckErr
call UMSSelectFlags(account,L,UMSMakeFlags(2),,,,U,UMSMakeFlags(UMSUSTAT_OLD,UMSUSTAT_READACCESS,UMSUSTAT_VIEWACCESS),UMSMakeFlags(UMSUSTAT_READACCESS,UMSUSTAT_VIEWACCESS));
call CheckErr
newmail = UMSSelectFlags(account,L,UMSMakeFlags(3),,,,L,UMSMakeFlags(0,1,2),UMSMakeFlags(0,1,2));
call CheckErr
say "New mails:" newmail
address PLAY
'ID Intercom'
if newmail = 0 then
'say sorry, no mail for you.'
else if newmail = 1 then
'say There is a new mail for you.'
else
'say There are ' || number(newmail) || ' new mails for you.'
i = 0
do forever
i = UMSSearchFlags(account,L,UMSMakeFlags(3),UMSMakeFlags(3),i);
if i = 0 then leave
drop msg.
call UMSReadMsgHeader(account,i,msg.,1);
call CheckErr
say i center(msg.UMSCODE_FROMNAME,24) || ":" left(msg.UMSCODE_SUBJECT,48)
'say from (' msg.UMSCODE_FROMNAME '),' translate(msg.UMSCODE_SUBJECT,",-",":/") '.'
end
call UMSSelectFlags(account,L,UMSMakeFlags(4),,,,U,UMSMakeFlags(UMSUSTAT_SELECTED),UMSMakeFlags(UMSUSTAT_SELECTED));
call CheckErr
newnews = UMSSelectFlags(account,L,UMSMakeFlags(5),,,,L,UMSMakeFlags(2,3,4),UMSMakeFlags(2,4));
call CheckErr
say "New selected news:" newnews
if newmail = 0 then intro = "But"
else intro = "And"
if newnews = 1 then
'say ' intro 'there is one new news addressed to you.'
else if newnews > 0 then
'say ' intro 'there are ' || number(newnews) || ' new news addressed to you.'
lastgroup = ""
i = 0
do forever
i = UMSSearchFlags(account,L,UMSMakeFlags(5),UMSMakeFlags(5),i);
if i = 0 then leave
drop msg.
call UMSReadMsgHeader(account,i,msg.,1);
call CheckErr
if msg.UMSCODE_GROUP = lastgroup then do
intro = ""
end; else do
lastgroup = msg.UMSCODE_GROUP
say "newsgroup:" lastgroup
intro = "In newsgroup (" || lastgroup || "),"
end
say i center(msg.UMSCODE_FROMNAME,24) || ":" left(msg.UMSCODE_SUBJECT,48)
'say ' || intro || ' from (' msg.UMSCODE_FROMNAME '),' translate(msg.UMSCODE_SUBJECT,",-",":/") '.'
end
if newmail > 0 then
'say ok, thats all.'
call HALT
/*** ***/
number: PROCEDURE
n = arg(1)
if n < 0 then n = "minus " || number(-n)
else if n = 11 then n = "eelaven"
else if n = 12 then n = "twelve"
else if n = 13 then n = "thirteen"
else if n = 15 then n = "fifteen"
else if (n > 13) & (n < 20) then n = (n // 10) || "teen"
else if n = 20 then n = "twenty"
else if (n > 20) & (n < 30) then n = "twenty " || (n // 10)
else if n = 30 then n = "thirty"
else if (n > 30) & (n < 40) then n = "thirty " || (n // 10)
else if n = 40 then n = "fourty"
else if (n > 40) & (n < 50) then n = "fourty " || (n // 10)
else if n = 50 then n = "fifty"
else if (n > 50) & (n < 60) then n = "fifty " || (n // 10)
else if n = 60 then n = "sixty"
else if (n > 60) & (n < 70) then n = "sixty " || (n // 10)
else if n = 70 then n = "seventy"
else if (n > 70) & (n < 80) then n = "seventy " || (n // 10)
else if n = 80 then n = "eighty"
else if (n > 80) & (n < 90) then n = "eighty " || (n // 10)
else if n = 90 then n = "nine-tee"
else if (n > 90) & (n < 100) then n = "nine-tee " || (n // 10)
else if n = 100 then n = "one hund-red"
else if n > 100 then n = number(n % 100) || " hund-red and " || number(n // 100)
return n
/*** Final cleanup ***/
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
ERROR:
HALT:
IOERR:
SYNTAX:
IF RC ~= 0 THEN DO
SAY "Error: " rc errortext(rc) "Line" sigl
END
/*** Logout ***/
if account ~= 0 then do
call UMSLogout(account)
account = 0
end
exit 0
/*** Support ***/
CheckErr: procedure expose account
err = UMSErrNum(account)
if err ~= 0 then do
say "UMS Error #" || err || ": " || UMSErrTxt(account)
end
return
FlagToStat: PROCEDURE
flags = arg(1)
status = '';
do i = 0 by 1 for arg()-1
if BITTST(flags,i) THEN
status = status arg(i+2)
end;
return status